require 'rubygems'
require 'savon'

class PaymentInfo
  def initialize
    @client_credit_card = Savon::Client.new do
      wsdl.document = "http://ec2-50-19-145-76.compute-1.amazonaws.com:8080/PagamentoCartao/PagamentoCartao?wsdl"
    end
  end
  
  def validate_purchase_credit_card(purchase_value, customer_name, card_brand, card_number, card_expiration, card_security_code, parcel_quantity)
    r = @client_credit_card.request :car, :valida_compra do
      soap.body = {
        "ValorDaCompra" => purchase_value,
        "NomeDoTitular" => customer_name,
        "BandeiraDoCartao" => card_brand,
        "NumeroDoCartao" => card_number,
        "DataDeValidade" => card_expiration,
        "CodigoDeSeguranca" => card_security_code,
        "QuantidadeDeParcelas" => parcel_quantity
      }
    end
    h = r.to_hash
    h[:valida_compra_response][:return]
  end
  
end